package com.burstly.lib.component;

import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout.LayoutParams;
import com.burstly.lib.network.beans.ResponseBean;
import com.burstly.lib.network.beans.ResponseBean.ResponseData;
import com.burstly.lib.network.beans.ResponseBean.ResponseData.AdType;
import com.burstly.lib.util.LoggerExt;

public class LayoutParametersResolver
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private final ResponseBean mFullResponse;
  private final ResponseBean.ResponseData mResponseData;
  private float mScale = 1.0F;
  private final String mTag;

  public LayoutParametersResolver(ResponseBean paramResponseBean, ResponseBean.ResponseData paramResponseData, String paramString)
  {
    this.mFullResponse = paramResponseBean;
    this.mResponseData = paramResponseData;
    this.mTag = paramString;
  }

  private FrameLayout.LayoutParams createLayoutParams(Integer paramInteger1, Integer paramInteger2)
  {
    LOG.logInfo(this.mTag, "Width : {0}, height: {1} are passed from server. ", new Object[] { paramInteger1, paramInteger2 });
    if ((paramInteger1 != null) && (paramInteger1.intValue() > 0) && (paramInteger2 != null) && (paramInteger2.intValue() > 0))
      return new FrameLayout.LayoutParams(parseSize(paramInteger1.intValue(), this.mScale), parseSize(paramInteger2.intValue(), this.mScale));
    return null;
  }

  private ViewGroup.LayoutParams getLayoutParams()
  {
    FrameLayout.LayoutParams localLayoutParams;
    if (this.mResponseData == null)
    {
      LOG.logWarning(this.mTag, "Current ad data has not been set in GS adaptor. Using WRAP_CONTENT...", new Object[0]);
      localLayoutParams = new FrameLayout.LayoutParams(-2, -2);
    }
    do
    {
      return localLayoutParams;
      ResponseBean.ResponseData.AdType localAdType = this.mResponseData.getAdType();
      localLayoutParams = null;
      if (localAdType != null)
      {
        LOG.logInfo(this.mTag, "Parsing width and height from AdType...", new Object[0]);
        localLayoutParams = createLayoutParams(localAdType.getWidth(), localAdType.getHeight());
      }
      if (localLayoutParams == null)
      {
        if (this.mFullResponse == null)
        {
          LOG.logWarning(this.mTag, "Full response has not been set in adaptor. Using WRAP_CONTENT...", new Object[0]);
          return new FrameLayout.LayoutParams(-2, -2);
        }
        LOG.logInfo(this.mTag, "Invalid parameters are in AdType. Parsing width and height from Response...", new Object[0]);
        localLayoutParams = createLayoutParams(this.mFullResponse.getWidth(), this.mFullResponse.getHeight());
      }
    }
    while (localLayoutParams != null);
    LoggerExt localLoggerExt = LOG;
    String str = this.mTag;
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = this.mFullResponse.getWidth();
    arrayOfObject[1] = this.mFullResponse.getHeight();
    localLoggerExt.logInfo(str, "Invalid sizes (width : {0}, height: {1}) are passed from server. Using WRAP_CONTENT...", arrayOfObject);
    return new FrameLayout.LayoutParams(-2, -2);
  }

  private int parseSize(int paramInt, float paramFloat)
  {
    if (paramInt > 0);
    for (float f = paramFloat * paramInt; ; f = -2.0F)
      return (int)f;
  }

  public float getScale()
  {
    return this.mScale;
  }

  public ViewGroup.LayoutParams resolveParameters()
  {
    return getLayoutParams();
  }

  public void setScale(float paramFloat)
  {
    this.mScale = paramFloat;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.LayoutParametersResolver
 * JD-Core Version:    0.6.2
 */